<?
if (!defined('IN_RJ')) die("Error 404");
if($cmd[1]=="tivi"){
	$data=$func->get_by_curl('http://vtc.com.vn/');
	if ($data){
		$ro=$tpl->get_tpl("television");
		$html='';
		$t['row'] = $tpl->get_block_from_str($ro,'list_tivi.row',1);
		preg_match_all("#id=='([0-9]+)'#",$data,$check);
		preg_match_all('#<a href=\'javascript\:void\(0\)\;\' onclick="javascript\:ChangeLiveProgram\(([0-9]+)\)"><img src=\'(.*?)\' border=\'0\' /></a>#',$data,$kenh);
	$type='';
		array_push($kenh[0],"hbo","espn");
		array_push($kenh[1],"hbo","espn");
		array_push($kenh[2],"{TPL_LINK}/img/tivi/hbo.jpg","{TPL_LINK}/img/tivi/espn.jpg");
		for($i=0;$i<count($kenh[0]);$i++){
			$tivi_id=$kenh[1][$i];
			for($j=0;$j<count($check[0]);$j++){
					if($kenh[1][$i]==$check[1][$j]){
						$type='lpid';
						break;
					}
					if(in_array($kenh[1][$i],array("hbo","espn"))){
						$type=$kenh[1][$i];
						break;
					}
			}
			if(in_array($tivi_id,array("hbo","espn")))
				$tivi_img=$kenh[2][$i];
			else
				$tivi_img="http://vtc.com.vn".$kenh[2][$i];
			$n=$i+1;		
			$tr=(fmod($n,3)==1)?'</tr><tr>':'';
			$html.=$tpl->assign_vars($t['row'],array(
					'tivi.IMG'		=> $tivi_img,
					'tivi.ONCLICK'	=> "change_channel('{$tivi_id}','{$type}');return false;",
					'tivi.TR'		=> $tr,
				)	
			);
		}		
			$ro = $tpl->assign_blocks_content($ro,array(
				'list_tivi'	=> $html,
				)
			);
	}
	else $ro=box_announcement($lang['no_data']);
		$main_content=$ro;
		$title_web_bar=$lang['television'];
		$title_ascii_web_bar=$func->utf8_to_ascii($lang['television']);
}
?>
